package cn.lintcode;

import java.io.*;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Arrays;

/**
 * @author labvi
 * @version 1.0.0
 */
public class IntersectionOfTwoArrays {
    private final static PrintWriter out = new PrintWriter(System.out);
    private final static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));


   /* public static void main(String[] args) throws IOException {
        StreamTokenizer scanner = new StreamTokenizer(bufferedReader);
        scanner.nextToken();
        int i1 = (int)scanner.nval;
        int[]  arr1 = new int[i1];
        for (int i = 0; i < i1; i++) {
            scanner.nextToken();
            arr1[i] = (int)scanner.nval;
        }
        scanner.nextToken();
        i1 = (int)scanner.nval;
        int[] arr2 = new int[i1];
        for (int i = 0; i < i1; i++) {
            scanner.nextToken();
            arr2[i] = (int)scanner.nval;
        }
        int i = 0;
        int j = 0;
        ArrayList<Integer> list = new ArrayList<>();
        while (i < arr1.length && j < arr2.length) {
            if (arr1[i] == arr2[j]) {
                if (!list.contains(arr1[i])) {
                    list.add(arr1[i]);
                }
                i++;
                j++;
                continue;
            }
            if (arr1[i] < arr2[j]) {
                i++;
            }else {
                j++;
            }
        }
        StringBuilder stringBuilder = new StringBuilder();
        String s = Arrays.toString(list.toArray());
        out.println(toMD5(s));
        out.flush();
    }*/

    public static void main(String[] args) throws IOException {
        int i1 = Integer.valueOf(bufferedReader.readLine());
        int[]  arr1 = new int[i1];
        for (int i = 0; i < i1; i++) {
            arr1[i] = Integer.valueOf(bufferedReader.readLine());
        }
        i1 = Integer.valueOf(bufferedReader.readLine());
        int[] arr2 = new int[i1];
        for (int i = 0; i < i1; i++) {
            arr2[i] = Integer.valueOf(bufferedReader.readLine());
        }
        int i = 0;
        int j = 0;
        ArrayList<Integer> list = new ArrayList<>();
        while (i < arr1.length && j < arr2.length) {
            if (arr1[i] == arr2[j]) {
                if (!list.contains(arr1[i])) {
                    list.add(arr1[i]);
                }
                i++;
                j++;
                continue;
            }
            if (arr1[i] < arr2[j]) {
                i++;
            }else {
                j++;
            }
        }
        String s = Arrays.toString(list.toArray());
        out.println(toMD5(s));
        out.flush();
        bufferedReader.close();
    }

    private static String toMD5(String plainText) {
        String result = "";
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(plainText.getBytes());
            byte b[] = md.digest();
            int i;
            StringBuffer buf = new StringBuffer("");
            for (int offset = 0; offset < b.length; offset++) {
                i = b[offset];
                if (i < 0){
                    i += 256;
                }
                if (i < 16) {
                    buf.append("0");
                }
                buf.append(Integer.toHexString(i));
            }
            result = buf.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
}
